package de.andreavicentini.teatralia.generate;

import org.magiclabs.htmlx.*;
import de.andreavicentini.teatralia.pages.*;
import de.andreavicentini.teatralia.pages.repertoire.*;

public class PlayRenderer<T> implements IRenderer<T> {
  protected static String nl;
  public static synchronized PlayRenderer create(String lineSeparator)
  {
    nl = lineSeparator;
    PlayRenderer result = new PlayRenderer();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "";
  protected final String TEXT_2 = NL;
  protected final String TEXT_3 = NL + " ";
  protected final String TEXT_4 = NL + "<p>";
  protected final String TEXT_5 = "</p>" + NL + "</div>";
  protected final String TEXT_6 = NL;

	public String generate(TeatraliaPage page, T argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append(TEXT_1);
     
Play play = (Play) argument;
 
    stringBuffer.append(TEXT_2);
    stringBuffer.append(TEXT_3);
    stringBuffer.append( new ToggleHeader(play.hashCode() + "", play.getTitle() + " (<a href=\"#" + play.getAuthor().getLastName() + "\"><span class=\"secondline\">" + play.getAuthor() + "</span></a>, <span class=\"secondline\">" + play.getDate() + ")</span>", play.getStyle()) );
    stringBuffer.append(TEXT_4);
    stringBuffer.append( page.getText(play.getDescription()) );
    stringBuffer.append(TEXT_5);
    stringBuffer.append(TEXT_6);
    return stringBuffer.toString();
  }
}